<template>
	<div class="update-pwd">
		<div>
			<label>{{$t('route.base')}}</label>
			<div></div>
			<button><img /><label>{{$t('route.Change_Password')}}</label></button>
		</div>
		<div>
			<el-form>
				<el-form-item :label="$t('route.select_encrypt')" label-width="150px">
					<el-input type="password" v-model="form.oldPwd" style="width: 300px;"></el-input>
				</el-form-item>
				<el-form-item :label="$t('route.New_Password')" label-width="150px">
					<el-input type="password" v-model="form.newPwd" style="width: 300px;"></el-input>
				</el-form-item>
				<el-form-item :label="$t('route.CONFIRM_PASSWORD')" label-width="150px">
					<el-input type="password" v-model="form.reNewPwd" style="width: 300px;"></el-input>
				</el-form-item>
				<el-form-item label-width="150px">
					<el-button type="primary" @click="confirmClick">{{$t('route.sure')}}</el-button>
				</el-form-item>
			</el-form>
		</div>

	</div>
</template>

<script>
	import http from "../../js/http/http.js";
	import api from "../../js/http/api.js";
	import CommonUtils from "../../js/common/common-utils.js";
	import md5 from '../../js/common/md5.js'
	import i18n from '../../i18n/index';
	export default {
		data() {
			return {
				form: {

				}
			};
		},
		methods: {
			confirmClick() {
				if (CommonUtils.isEmpty(this.form.oldPwd) ||
					CommonUtils.isEmpty(this.form.newPwd)) {
					this.$message.error(i18n.global.t('route.Password_cannot_be_empty'));
					return;
				}
				if (this.form.newPwd != this.form.reNewPwd) {
					this.$message.error(i18n.global.t('route.The_two_passwords_are_inconsistent'));
					return;
				}
				http.post(api.UPDATE_ADMIN_PWD, {
						adminId: this.$store.state.user.id,
						oldPwd: md5(this.form.oldPwd),
						newPwd: md5(this.form.newPwd),
					},
					data => {
						this.$message.success(i18n.global.t('route.Password_modified_successfully'));
					}
				);
			}

		},
		created() {




		}
	};
</script>
<style lang="scss" scoped>
	.update-pwd {
		color: #444444;
		font-size: 18px;
		padding-right: 20px;
		height: calc(100vh - 100px);
		// overflow: scroll;
		scrollbar-width: none;
		/* firefox */
		-ms-overflow-style: none;
		/* IE 10+ */
		overflow-x: hidden;
		overflow-y: auto;

		>div {
			display: flex;
			flex-direction: row;
			align-items: center;
			margin-top: 20px;
			background-color: #ffffff;
			padding: 20px;
			border-radius: 5px;
		}

		>div:nth-of-type(1) {


			>label:nth-of-type(1) {
				font-weight: 600;
			}

			>div:nth-of-type(1) {
				width: 1px;
				background-color: #cccccc;
				height: 15px;
				margin: 0px 20px;
			}

			>button:nth-of-type(1) {
				background-image: url(../../assets/img/customer-1.png);
				background-repeat: no-repeat;
				background-size: 100% 100%;
				padding: 5px 10px;
				border: 0px;
				display: flex;
				color: #ffffff;
				flex-direction: row;
				align-items: center;
				font-weight: 800;

				>img {
					margin-right: 7px;
					width: 15px;
					height: 15px;
					content: url(../../assets/img/customer-2.png);
				}

			}
		}
	}
</style>
